<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_report" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="reportDataSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/mes/systemadmin/ReportDetail?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 修改报表 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="报表数据" prop="sql_id">
              <el-select style='width:100%' v-model="s_report.sql_id">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in get_report" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 报表参数 </span>
      </div>
      <el-table :data="s_params">
        <el-table-column label="参数" prop="name">
        </el-table-column>
        <el-table-column label="参数说明" prop="description">
        </el-table-column>
        <el-table-column label="sql列" prop="sql_col">
          <template slot-scope="scope">
            <el-input v-model="scope.row.sql_col" />
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 列表参数 </span>
      </div>
      <el-table :data="s_list">
        <el-table-column label="名称" prop="name">
        </el-table-column>
        <el-table-column label="参数说明" prop="description">
        </el-table-column>
        <el-table-column label="sql列" prop="sql_col">
          <template slot-scope="scope">
            <el-input v-model="scope.row.sql_col" />
          </template>
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ReportData',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_report: {
          sql_id: null,
        },
        s_params: [],
        s_list: [],
        get_report: [],
        loading: false,
        rules: {
          sql_id: [{
            required: true,
            message: "报表数据不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/systemadmin/ReportAdminAction/reportData?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      reportDataSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/systemadmin/ReportAdminAction/reportDataSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/systemadmin/ReportDetail/reportDetail?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
